const express = require('express');
const router = express.Router();
const queryService = require('../services/queryService');

router.post('/data', async (req, res) => {
  try {
    const response = await queryService.queryTable(req.body);
    res.status(200).json(response);
  } catch (error) {
    console.error('Query error:', error);
    res.status(200).json({
      code: '-1',
      data: { table: '', list: [] },
      msg: 'Internal server error'
    });
  }
});

module.exports = router; 